home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGASIC / BASICTUT.LZH / INPUT.BAS < prev    next >
BASIC Source File  |  1980-01-01  |  7KB  |  138 lines

  1. 10 REM MARK A. SWANSON    20:43:15   02-24-85
  2. 20 CLS
  3. 30 FOR A=1 TO 312:PRINT " ? ";:NEXT A
  4. 40 PRINT "------------------------------------------------------------------------------"
  5. 50 PRINT:PRINT
  6. 60 PRINT "                                    I N P U T
  7. 70 PRINT
  8. 80 PRINT "                       THE QUESTION TO ALL OF YOUR ANSWERS
  9. 90 FOR A=1 TO 2000:NEXT A
  10. 100 CLS
  11. 110 PRINT "            If you've ever wondered how a computer can not only ask
  12. 120 PRINT "            us a question, but respond as well, wonder no more !
  13. 130 PRINT
  14. 140 PRINT "            INPUT is a STATEMENT that allows a request for data to be
  15. 150 PRINT "            'put in' to the computer's memory.  With this powerfull
  16. 160 PRINT "            STATEMENT we can communicate (and to stretch the truth a
  17. 170 PRINT "            bit, converse) with the computer.  Below is an example....
  18. 180 PRINT
  19. 190 PRINT "                              Go ahead and answer.....
  20. 200 PRINT
  21. 210 INPUT "                          WHAT IS YOUR NAME, FRIEND ";N$
  22. 220 PRINT "                          HI, ";N$
  23. 230 PRINT:PRINT:PRINT
  24. 240 FOR A=1 TO 1000:NEXT A
  25. 250 PRINT "            As you can see ";N$;", I now know your name and can use
  26. 260 PRINT "            it throughout this lesson if I want to !  Let's see how 
  27. 270 PRINT "            this STATEMENT looks.
  28. 280 PRINT:PRINT:PRINT
  29. 290 INPUT "                PRESS [RETURN] TO CONTINUE     [Q] MAIN BTMENU ";Z$
  30. 291 IF Z$="Q" THEN LOAD"B:BTMENU.BAS",R
  31. 300 CLS
  32. 310 PRINT "                      10 INPUT ''WHAT IS YOUR NAME, FRIEND '';N$
  33. 320 PRINT "                      20 PRINT ''HI, '';N$"
  34. 330 PRINT
  35. 340 PRINT "            This may look complicated, but it isn't.  Let's disect it.
  36. 350 PRINT 
  37. 360 PRINT "            Line 10 holds the INPUT STATEMENT.  Notice that the question
  38. 370 PRINT "            is typed in just as we would like it, except we leave out
  39. 380 PRINT "            question mark (?).  The computer will automatically place
  40. 390 PRINT "            the '?' at the end (where the semi-colon is).  Quotations
  41. 400 PRINT "            are necessary as with the PRINT STATEMENT.  At the end of
  42. 410 PRINT "            the line a VARIABLE is used to store the answer.  Our answer
  43. 420 PRINT "            is a STRING (a word or letter) so the '$' is added.
  44. 430 PRINT
  45. 440 PRINT "            Line 20 PRINTs the response.  Note that the semi-colon
  46. 450 PRINT "            separates the STRING from the VARIABLE (N$).  Remember,
  47. 460 PRINT "            a semi-colon tells the computer to PRINT the following
  48. 470 PRINT "            data right after the preceding data (on the same line if
  49. 480 PRINT "            there is enough room on the screen).  In short, the computer
  50. 490 PRINT "            is instructed to PRINT two things - the STRING (HI, ) and
  51. 500 PRINT "            the data stored to the VARIABLE N$ (";N$;")."
  52. 510 PRINT:PRINT
  53. 520 INPUT "         PRESS [RETURN] TO CONTINUE  [P] PREVIOUS PAGE  [Q] MAIN BTMENU ";Z$
  54. 530 IF Z$="P" THEN GOTO 100
  55. 540 IF Z$="Q" THEN LOAD"B:BTMENU.BAS",R
  56. 550 CLS
  57. 560 PRINT "           Now we'll use INPUT with numbers (no STRINGs attached !).
  58. 570 PRINT
  59. 580 PRINT "                        10 INPUT ''HOW OLD ARE YOU '';A
  60. 590 PRINT "                        20 PRINT ''YOU ARE '';A;'' YEARS OLD''
  61. 600 PRINT
  62. 610 PRINT "          Line 10 is typed in just like the previous program with one
  63. 620 PRINT "          exception - the '$' sign is left off the VARIABLE 'A'.
  64. 630 PRINT
  65. 640 PRINT "          Line 20 is set up just like line 20 in the previous program
  66. 650 PRINT "          with the additional STRING at the end (''YEARS OLD'').  Again
  67. 660 PRINT "          we used semi-colons to separate the data to be PRINTed.
  68. 670 PRINT 
  69. 680 PRINT "          Ok, go ahead and answer again.....
  70. 690 PRINT
  71. 700 INPUT "                             HOW OLD ARE YOU ";A
  72. 710 PRINT "                             YOU ARE ";A;" YEARS OLD"
  73. 720 PRINT:PRINT
  74. 730 FOR A=1 TO 1000:NEXT A
  75. 740 PRINT "          If you were to type a STRING (letter or word) instead of a
  76. 750 PRINT "          number (as is required by the VARIABLE 'A') the message
  77. 760 PRINT "          '?redo from start' would appear and allow you to re-enter a number.
  78. 770 PRINT:PRINT
  79. 780 INPUT "        PRESS [RETURN] TO CONTINUE  [P] PREVIOUS PAGE  [Q] MAIN BTMENU ";Z$
  80. 790 IF Z$="P" THEN GOTO 300
  81. 800 IF Z$="Q" THEN LOAD"B:BTMENU.BAS",R
  82. 810 CLS
  83. 820 PRINT "           Here's an example of some fancy programming.....
  84. 830 PRINT
  85. 840 PRINT "                 10 INPUT ''WHAT IS YOUR NAME '';NM$
  86. 850 PRINT "                 20 PRINT ''HI, '';NM$
  87. 860 PRINT "                 30 PRINT ''TYPE 3 NUMBERS AND I'LL PRINT THE AVERAGE''
  88. 870 PRINT "                 40 INPUT ''1ST NUMBER '';A
  89. 880 PRINT "                 50 INPUT ''2ND NUMBER '';B
  90. 890 PRINT "                 60 INPUT ''3RD NUMBER '';C
  91. 900 PRINT "                 70 PRINT (A+B+C)/3
  92. 910 PRINT
  93. 920 PRINT "          Take a good look at this program, line for line, so you will
  94. 930 PRINT "          understand what each STATEMENT will do.   Ok, now answer
  95. 940 PRINT "          the questions.....
  96. 950 PRINT
  97. 960 INPUT "                    WHAT IS YOUR NAME ";NM$
  98. 970 PRINT "                    HI ";NM$
  99. 980 PRINT "                    TYPE 3 NUMBERS AND I'LL PRINT THE AVERAGE 
  100. 990 INPUT "                    1ST NUMBER ";A
  101. 1000 INPUT "                    2ND NUMBER ";B
  102. 1010 INPUT "                    3RD NUMBER ";C
  103. 1020 PRINT "                   ";(A+B+C)/3
  104. 1030 PRINT
  105. 1040 PRINT "          What would you add to line 70 to have the computer PRINT
  106. 1050 PRINT "          'THE AVERAGE IS;(A+B+C)/3' ?  {PRINT ''THE AVERAGE IS'';(A+B+C)/3}
  107. 1060 PRINT
  108. 1070 INPUT "          PRESS [RETURN] TO CONTINUE  [P] PREVIOUS PAGE  [Q] MAIN BTMENU ";Z$
  109. 1080 IF Z$="P" THEN GOTO 550
  110. 1090 IF Z$="Q" THEN LOAD"B:BTMENU.BAS",R
  111. 1100 CLS
  112. 1110 PRINT "IN SUMMARY.......
  113. 1120 PRINT
  114. 1130 PRINT "            1.  INPUT instructs the computer to accept and store data
  115. 1140 PRINT "                in response to user defined questions and inquiries
  116. 1150 PRINT
  117. 1160 PRINT "            2.  The format is:  STATEMENT ''ARGUMENT'';VARIABLE
  118. 1170 PRINT "                       example>  INPUT ''NAME PLEASE'';N$
  119. 1180 PRINT
  120. 1190 PRINT "------------------------------------------------------------------------------"
  121. 1200 PRINT "FOR PRACTICE.......
  122. 1210 PRINT
  123. 1220 PRINT "            1.  Create programs like the examples using.....
  124. 1230 PRINT "              a.  STRING data as responses
  125. 1240 PRINT "              b.  NUMBER data as responses
  126. 1250 PRINT
  127. 1260 PRINT "            2.  Create a program using INPUT with FOR/NEXT and GOTO
  128. 1270 PRINT:PRINT:PRINT:PRINT:PRINT
  129. 1280 INPUT "           PRESS [Z] TO PRACTICE  [P] PREVIOUS PAGE  [Q] MAIN BTMENU ";Z$
  130. 1290 IF Z$="P" THEN GOTO 810
  131. 1300 IF Z$="Q" THEN LOAD"B:BTMENU.BAS",R
  132. 1310 CLS
  133. 1320 PRINT "                             To practice, type NEW
  134. 1330 PRINT "               To get back to lessons, type LOAD''B:BTMENU.BAS'',R
  135. 1340 PRINT
  136. 1350 PRINT "        Remember to use quotations instead of double appostrophies ('')
  137. 1360 PRINT "------------------------------------------------------------------------------"
  138.